<?php
/**
 * Moduleadmin_Model_Insertmodule
 * insert new module model
 * @author Adrian Stolarski
 */
class Moduleadmin_Model_Insertmodule implements Moduleadmin_Model_Mainable, 
        Moduleadmin_Model_Decidable {
    
    /**
     *
     * @var type $action_handler
     * current action handler
     */
    public $action_handler;
    public function main(array $variables = null) {
        //var_dump($variables);
        //die();
        if(
                isset($variables['module_name']) 
                && isset($variables['module_title']) 
                && isset($variables['module_keywords']) 
                && isset($variables['module_description'])
                ){
            $this->model_decision($variables);
        }
        else {
            $this->action_handler = new Moduleadmin_Data_Addactionredirect;
            $this->action_handler->main($variables);
        }
    }
    
    /**
     * model_decision()
     * insert module data
     * 
     * @param array $variables
     */
    public function model_decision(array $variables = null) {
        //var_dump($variables);
        //die();
        if(
                !is_null($variables['module_name']) 
                && !is_null($variables['module_title']) 
                && !is_null($variables['module_keywords']) 
                && !is_null($variables['module_description'])
                ){
            $this->action_handler = new Moduleadmin_Data_Insertmodule;
            $this->action_handler->main($variables);
        }
        else {
            $this->action_handler = new Moduleadmin_Data_Addactionredirect;
            $this->action_handler->main($variables);
        }
    }

}
